package com.legal.controller.practice;


import com.legal.domain.po.practice_view.PracticeRecordsListView;
import com.legal.domain.po.practice_view.RecordDetailsView;
import com.legal.domain.result.Result;
import com.legal.service.practice.impl.view.IPracticeRecordsListViewService;
import com.legal.service.practice.impl.view.IRecordDetailsViewService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 刷题功能模块 - 刷题记录 控制器
 * </p>
 *
 * @author xiaopeng
 * @since 2025-06-27
 */
@RestController
@RequestMapping("/record")
@RequiredArgsConstructor
@Tag(name = "刷题记录管理")  // OpenAPI 3.0 注解
public class RecordController {

    private final IPracticeRecordsListViewService practiceRecordsListViewService;

    private final IRecordDetailsViewService recordDetailsViewService;

    /**
     * 根据用户编号 获取用户的所有刷题历史记录列表
     *
     * @return
     */
    @Operation(summary = "获取用户的所有刷题历史记录列表")
    @GetMapping("/historyList")
    public Result<List<PracticeRecordsListView>> historyList(@RequestParam("userNo") String userNo) {
        return Result.ok(practiceRecordsListViewService.getHistoryListByUserNo(userNo));
    }

    /**
     * 根据记录编号 获取用户某条刷题记录的详情
     * @param recordNo 记录编号
     * @return 某条刷题记录的详情信息
     */
    @Operation(summary = "获取刷题记录的详情信息")
    @GetMapping("/detail")
    public Result<List<RecordDetailsView>> getPracticeRecordDetailsByRecordNo(@RequestParam("recordNo") String recordNo) {
        return Result.ok(recordDetailsViewService.getPracticeRecordDetailsByRecordNo(recordNo));
    }
    @Operation(summary = "根据recordNo获取刷题记录")
    @GetMapping("/find")
    public Result<PracticeRecordsListView> getPracticeRecordByRecordNo(@RequestParam("recordNo") String recordNo) {
        return Result.ok(practiceRecordsListViewService.getPracticeRecordByRecordNo(recordNo));
    }


}
